import { defineStore } from "pinia";
import { ref } from "vue";

export const useToken = defineStore("token", () => {
    const token = ref<string | null>(null)

    // 获取token
    const getToken = () => {
        return token.value
    }

    // 设置token
    const setToken = (value:string) => {
        token.value = value
    }

    // 删除token
    const removeToken = () => {
        token.value = null
    }

    return{ token,getToken,setToken,removeToken}
},
    {
        persist: true
})
